<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar.jpg">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-big-counter.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"raphets.github.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"hide","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"default"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="记录一下本网站的搭建过程">
<meta property="og:type" content="article">
<meta property="og:title" content="GitHub + Hexo 搭建个人博客教程">
<meta property="og:url" content="https://raphets.github.io/archives/19105.html">
<meta property="og:site_name" content="尚拙">
<meta property="og:description" content="记录一下本网站的搭建过程">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2019-03-21T10:34:41.000Z">
<meta property="article:modified_time" content="2024-09-12T02:53:57.343Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="Hexo">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://raphets.github.io/archives/19105.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>GitHub + Hexo 搭建个人博客教程 | 尚拙</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">尚拙</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">一个分享技术、学习成长的个人博客网站</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-tool">

    <a href="/tool/" rel="section"><i class="fa fa-hammer fa-fw"></i>工具</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://raphets.github.io/archives/19105.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="John Doe">
      <meta itemprop="description" content="不积跬步，无以至千里；不积小流，无以成江海。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="尚拙">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          GitHub + Hexo 搭建个人博客教程
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-03-21 18:34:41" itemprop="dateCreated datePublished" datetime="2019-03-21T18:34:41+08:00">2019-03-21</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-09-12 10:53:57" itemprop="dateModified" datetime="2024-09-12T10:53:57+08:00">2024-09-12</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/" itemprop="url" rel="index"><span itemprop="name">技术文章</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/%E5%85%B6%E4%BB%96/" itemprop="url" rel="index"><span itemprop="name">其他</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>记录一下本网站的搭建过程</p>
<span id="more"></span>

<h1 id="一、前言"><a href="#一、前言" class="headerlink" title="一、前言"></a>一、前言</h1><p>本教程只针对win10系统，写的比较精简，方便自己以后查看，适合有一定技术基础的人阅读。</p>
<p>本博客基于Hexo+GitHub搭建，也可以使用码云Gitee，原理是一样的。</p>
<p>搭建博客过程其实比较简单，主要是后期主题优化修改比较花时间。</p>
<h1 id="二、准备工作"><a href="#二、准备工作" class="headerlink" title="二、准备工作"></a>二、准备工作</h1><p>系统环境：win10系统</p>
<p>1、安装Git</p>
<p>官网<a target="_blank" rel="noopener" href="https://git-scm.com/">https://git-scm.com/</a></p>
<p>2、安装node.js</p>
<p>官网<a target="_blank" rel="noopener" href="https://nodejs.org/en/">https://nodejs.org/en/</a></p>
<p>3、注册一个GitHub账号</p>
<p>官网<a target="_blank" rel="noopener" href="https://github.com/">https://github.com/</a></p>
<p>登录Github，新建一个仓库，命名为username.github.io，其中username为你的Github用户名。</p>
<p>例如我新建的仓库为raphets.github.io，那么后面我们就可以通过<a href="https://raphets.github.io/%E8%AE%BF%E9%97%AE%E6%88%91%E4%BB%AC%E7%9A%84%E5%8D%9A%E5%AE%A2%E3%80%82">https://raphets.github.io/访问我们的博客。</a></p>
<p>注意，username必须是你的用户名</p>
<h1 id="三、Hexo环境搭建"><a href="#三、Hexo环境搭建" class="headerlink" title="三、Hexo环境搭建"></a>三、Hexo环境搭建</h1><p>官方文档：<a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/docs/">https://hexo.io/zh-cn/docs/</a></p>
<h3 id="1、hexo简介"><a href="#1、hexo简介" class="headerlink" title="1、hexo简介"></a>1、hexo简介</h3><p>Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown（或其他渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页。</p>
<h3 id="2、安装"><a href="#2、安装" class="headerlink" title="2、安装"></a>2、安装</h3><p>在任意一个地方新建一个文件夹，用以存放本地博客文件，比如我的是E:\Blog</p>
<p>进入该文件夹，右键选择git bash进入git命令行，输入以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">npm install -g hexo</span><br></pre></td></tr></table></figure>
<h3 id="3、初始化"><a href="#3、初始化" class="headerlink" title="3、初始化"></a>3、初始化</h3><p>继续输入命令进行初始化</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo init</span><br></pre></td></tr></table></figure>
<h3 id="5、生成静态文件"><a href="#5、生成静态文件" class="headerlink" title="5、生成静态文件"></a>5、生成静态文件</h3><p>继续输入命令生成静态文件</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo g</span><br></pre></td></tr></table></figure>
<h3 id="6、启动服务"><a href="#6、启动服务" class="headerlink" title="6、启动服务"></a>6、启动服务</h3><p>继续输入命令开启本地预览服务</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<p>此时打开浏览器访问 <a href="http://localhost:4000，即可看到内容，hexo环境到此已经搭建完成">http://localhost:4000，即可看到内容，hexo环境到此已经搭建完成</a></p>
<h3 id="7、-hexo常见命令说明"><a href="#7、-hexo常见命令说明" class="headerlink" title="7、 hexo常见命令说明"></a>7、 hexo常见命令说明</h3><h6 id="清除缓存文件-db-json-和已生成的静态文件-public"><a href="#清除缓存文件-db-json-和已生成的静态文件-public" class="headerlink" title="清除缓存文件 (db.json) 和已生成的静态文件 (public)"></a>清除缓存文件 (db.json) 和已生成的静态文件 (public)</h6><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo clean</span><br></pre></td></tr></table></figure>
<p>在某些情况（尤其是更换主题后），如果发现您对站点的更改无论如何也不生效，您可能需要运行该命令。</p>
<h6 id="生成静态文件"><a href="#生成静态文件" class="headerlink" title="生成静态文件"></a>生成静态文件</h6><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo g</span><br></pre></td></tr></table></figure>
<p>每次对博客文件或者相关配置进行了修改，需要执行该命令</p>
<h6 id="启动服务器"><a href="#启动服务器" class="headerlink" title="启动服务器"></a>启动服务器</h6><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<p>默认情况下，访问网址为：<a target="_blank" rel="noopener" href="http://localhost:4000/">http://localhost:4000/</a><br>可以在本地对修改进行预览。</p>
<h6 id="部署网站"><a href="#部署网站" class="headerlink" title="部署网站"></a>部署网站</h6><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo d</span><br></pre></td></tr></table></figure>
<p>将本地博客部署到GitHub上</p>
<h6 id="新建文章"><a href="#新建文章" class="headerlink" title="新建文章"></a>新建文章</h6><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo new &quot;article&quot; </span><br></pre></td></tr></table></figure>

<h6 id="新建页面"><a href="#新建页面" class="headerlink" title="新建页面"></a>新建页面</h6><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo new page &quot;pageName&quot;</span><br></pre></td></tr></table></figure>
<h1 id="四、将本地博客部署到GitHub"><a href="#四、将本地博客部署到GitHub" class="headerlink" title="四、将本地博客部署到GitHub"></a>四、将本地博客部署到GitHub</h1><h3 id="Github地址配置"><a href="#Github地址配置" class="headerlink" title="Github地址配置"></a>Github地址配置</h3><p>先配置博客根目录下_config.yml文件的deploy部分：</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repository: https://username:password@github.com/RaphetS/RaphetS.github.io.git</span><br><span class="line">  branch: master</span><br></pre></td></tr></table></figure>
<p>其中username为Github账号的用户名，password为Github账号的密码。</p>
<p>账号、密码后面的部分为你的仓库地址</p>
<h3 id="发布博客"><a href="#发布博客" class="headerlink" title="发布博客"></a>发布博客</h3><p>在博客的根目录的git命令行中，执行hexo -d命令，就把本地博客部署到了Github上了。</p>
<p>过一段时间，访问<a target="_blank" rel="noopener" href="https://username.github.io就能访问你的博客了,username为你的github用户名/">https://username.github.io就能访问你的博客了，username为你的Github用户名</a></p>
<h1 id="五、博客美化"><a href="#五、博客美化" class="headerlink" title="五、博客美化"></a>五、博客美化</h1><p>hexo 默认的主题比较丑，为了能够更好的装B，我们需要把博客美化一下，显得有逼格一些。</p>
<h3 id="更换主题"><a href="#更换主题" class="headerlink" title="更换主题"></a>更换主题</h3><p><a target="_blank" rel="noopener" href="https://hexo.io/themes/">https://hexo.io/themes/</a></p>
<p>这是官方主题网站，你可以去上面找你自己想要的主题。</p>
<p>我用的是Next主题，GitHub地址<a target="_blank" rel="noopener" href="https://github.com/iissnan/hexo-theme-next">https://github.com/iissnan/hexo-theme-next</a></p>
<h6 id="1、下载主题"><a href="#1、下载主题" class="headerlink" title="1、下载主题"></a>1、下载主题</h6><p>在博客根目录打开git命令行，输入以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">git clone https://github.com/iissnan/hexo-theme-next themes/next</span><br></pre></td></tr></table></figure>
<p>主题会下载到themes文件夹内</p>
<h6 id="2、使用主题"><a href="#2、使用主题" class="headerlink" title="2、使用主题"></a>2、使用主题</h6><p>打开博客根目录下_config.yml文件，找到theme配置，设置为next</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">theme: next</span><br></pre></td></tr></table></figure>
<p>然后使用hexo g重新生成静态页面，hexo s 打开本地服务，可以去localhost:4000&#x2F;中查看效果了。</p>
<h1 id="六、添加gitment评论系统"><a href="#六、添加gitment评论系统" class="headerlink" title="六、添加gitment评论系统"></a>六、添加gitment评论系统</h1><p>Gitment 是作者实现的一款基于 GitHub Issues 的评论系统。<br>支持在前端直接引入，不需要任何后端代码。<br>可以在页面进行登录、查看、评论、点赞等操作，同时有完整的 Markdown &#x2F; GFM 和代码高亮支持。<br>尤为适合各种基于 GitHub Pages 的静态博客或项目页面。</p>
<h4 id="1、安装Gitment"><a href="#1、安装Gitment" class="headerlink" title="1、安装Gitment"></a>1、安装Gitment</h4><p>在你的blog根目录打开git命令行，输入以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">npm i --save gitment</span><br></pre></td></tr></table></figure>

<h4 id="2、注册-OAuth-Application"><a href="#2、注册-OAuth-Application" class="headerlink" title="2、注册 OAuth Application"></a>2、注册 OAuth Application</h4><p>首先去<a target="_blank" rel="noopener" href="https://github.com/settings/applications/new">OAuth Application</a>来注册一个新的 OAuth Application。</p>
<p>其中Authorization callback URL必须填写博客的地址，比如我的就是<a href="https://raphets.github.io/%EF%BC%8C%E5%85%B6%E4%BB%96%E7%9A%84%E9%9A%8F%E4%BE%BF%E5%A1%AB%E3%80%82">https://raphets.github.io/，其他的随便填。</a></p>
<p>注册之后会得到 client ID 和一个 client secret，后面会用到。</p>
<h4 id="3、Gitment配置"><a href="#3、Gitment配置" class="headerlink" title="3、Gitment配置"></a>3、Gitment配置</h4><p>打开theme的_config.yml文件，我的文件目录是themes&#x2F;next&#x2F;_config.yml，中间的next就是当前使用的theme的文件夹。</p>
<p>最新版本next主题默认已经集成了Gitment的，我们找到themes&#x2F;next&#x2F;_config.yml文件中Gitment配置，进行如下修改</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line"># Gitment</span><br><span class="line"># Introduction: https://imsun.net/posts/gitment-introduction/</span><br><span class="line"># You can get your Github ID from https://api.github.com/users/&lt;Github username&gt;</span><br><span class="line">gitment:</span><br><span class="line">  enable: true</span><br><span class="line">  mint: true # RECOMMEND, A mint on Gitment, to support count, language and proxy_gateway</span><br><span class="line">  count: true # Show comments count in post meta area</span><br><span class="line">  lazy: false # Comments lazy loading with a button</span><br><span class="line">  cleanly: true # Hide &#x27;Powered by ...&#x27; on footer, and more</span><br><span class="line">  language: # Force language, or auto switch by theme</span><br><span class="line">  github_user: RaphetS # 修改为你的Github用户名</span><br><span class="line">  github_repo: RaphetS.github.io # 写一个你的Github公开的仓库，到时候评论会作为那个项目的issue，这里用的是博客的项目</span><br><span class="line">  client_id: ae52f8c2g50g3dag73 # 上一步申请的ClientID</span><br><span class="line">  client_secret: a54ag44ag784te4g85e4g # 上一步申请的Client Secret</span><br><span class="line">  proxy_gateway: # Address of api proxy, See: https://github.com/aimingoo/intersect</span><br><span class="line">  redirect_protocol: # Protocol of redirect_uri with force_redirect_protocol when mint enabled</span><br></pre></td></tr></table></figure>
<p>其中github_user、github_repo、client_id、client_secret要换成你自己的。</p>
<h4 id="4、初始化评论"><a href="#4、初始化评论" class="headerlink" title="4、初始化评论"></a>4、初始化评论</h4><p>页面发布后，你需要访问页面并使用你的 GitHub 账号登录（请确保你的账号是第二步所填 repo 的 owner），点击初始化按钮。</p>
<p>之后其他用户即可在该页面发表评论。</p>
<h4 id="5、关闭某个页面的评论功能"><a href="#5、关闭某个页面的评论功能" class="headerlink" title="5、关闭某个页面的评论功能"></a>5、关闭某个页面的评论功能</h4><p>以上步骤集成评论功能之后，发现所有的页面都有评论功能，比如标签页面、分类页面也有评论功能，但是不想要，如何关闭呢？</p>
<p>在页面的 Front-matter 里添加 comments 字段，并将值设置为 false。如下所示：</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">title: 目录</span><br><span class="line">date: 2019-03-21 17:00:15</span><br><span class="line">type: &quot;categories&quot;</span><br><span class="line">comments: false</span><br></pre></td></tr></table></figure>
<p>即新建文章的md文件的头部，添加comments字段，并且设置为false。</p>
<h4 id="6、问题"><a href="#6、问题" class="headerlink" title="6、问题"></a>6、问题</h4><h5 id="登录报错，Object-ProgressEvent"><a href="#登录报错，Object-ProgressEvent" class="headerlink" title="登录报错，Object ProgressEvent"></a>登录报错，Object ProgressEvent</h5><p>原因：貌似是作者的服务器停掉了。</p>
<p>解决办法：</p>
<p>找到themes\hexo-theme-next\layout_third-party\comments\gitment.swig文件，</p>
<p>将以下代码</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">&lt;!-- LOCAL: You can save these files to your site and update links --&gt;</span><br><span class="line">    &#123;% if theme.gitment.mint %&#125;</span><br><span class="line">        &#123;% set CommentsClass = &quot;Gitmint&quot; %&#125;</span><br><span class="line">        &lt;link rel=&quot;stylesheet&quot; href=&quot;https://aimingoo.github.io/gitmint/style/default.css&quot;&gt;</span><br><span class="line">        &lt;script src=&quot;https://aimingoo.github.io/gitmint/dist/gitmint.browser.js&quot;&gt;&lt;/script&gt;</span><br><span class="line">    &#123;% else %&#125;</span><br><span class="line">        &#123;% set CommentsClass = &quot;Gitment&quot; %&#125;</span><br><span class="line">      &lt;link rel=&quot;stylesheet&quot; href=&quot;//imsun.github.io/gitment/style/default.css&quot;&gt;</span><br><span class="line">      &lt;script src=&quot;//imsun.github.io/gitment/dist/gitment.browser.js&quot;&gt;&lt;/script&gt;</span><br><span class="line">    &#123;% endif %&#125;</span><br><span class="line">&lt;!-- END LOCAL --&gt;</span><br></pre></td></tr></table></figure>
<p>替换为</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">&lt;!-- LOCAL: You can save these files to your site and update links --&gt;</span><br><span class="line">    &#123;% if theme.gitment.mint %&#125;</span><br><span class="line">        &#123;% set CommentsClass = &quot;Gitmint&quot; %&#125;</span><br><span class="line">        &lt;link rel=&quot;stylesheet&quot; href=&quot;https://aimingoo.github.io/gitmint/style/default.css&quot;&gt;</span><br><span class="line">        &lt;script src=&quot;https://aimingoo.github.io/gitmint/dist/gitmint.browser.js&quot;&gt;&lt;/script&gt;</span><br><span class="line">    &#123;% else %&#125;</span><br><span class="line">        &#123;% set CommentsClass = &quot;Gitment&quot; %&#125;</span><br><span class="line">        &lt;link rel=&quot;stylesheet&quot; href=&quot;https://jjeejj.github.io/css/gitment.css&quot;&gt;</span><br><span class="line">        &lt;script src=&quot;https://jjeejj.github.io/js/gitment.js&quot;&gt;&lt;/script&gt;</span><br><span class="line">    &#123;% endif %&#125;</span><br><span class="line">&lt;!-- END LOCAL --&gt;</span><br></pre></td></tr></table></figure>


<h1 id="七、其他"><a href="#七、其他" class="headerlink" title="七、其他"></a>七、其他</h1><h4 id="设置「阅读全文」"><a href="#设置「阅读全文」" class="headerlink" title="设置「阅读全文」"></a>设置「阅读全文」</h4><p>在首页显示一篇文章的部分内容，并提供一个链接跳转到全文页面是一个常见的需求。 NexT 提供三种方式来控制文章在首页的显示方式。 也就是说，在首页显示文章的摘录并显示 阅读全文 按钮，可以通过以下方法：</p>
<p>1、在文章中使用 <!-- more --> 手动进行截断，Hexo 提供的方式</p>
<p>2、在文章的 front-matter 中添加 description，并提供文章摘录</p>
<p>3、自动形成摘要，在主题配置文件theme&#x2F;next&#x2F;_config.yml 中添加</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">auto_excerpt:</span><br><span class="line">  enable: true</span><br><span class="line">  length: 150</span><br></pre></td></tr></table></figure>
<p>默认截取的长度为 150 字符，可以根据需要自行设定</p>
<h4 id="首页文章添加阴影效果"><a href="#首页文章添加阴影效果" class="headerlink" title="首页文章添加阴影效果"></a>首页文章添加阴影效果</h4><p>修改custom.styl 文件，具体为themes&#x2F;next&#x2F;source&#x2F;css&#x2F;_custom&#x2F;custom.styl，添加一下代码</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">// 主页文章添加阴影效果</span><br><span class="line">.post &#123;</span><br><span class="line">   margin-top: 0px;</span><br><span class="line">   margin-bottom: 60px;</span><br><span class="line">   padding: 25px;</span><br><span class="line">   -webkit-box-shadow: 0 0 5px rgba(202, 203, 203, .5);</span><br><span class="line">   -moz-box-shadow: 0 0 5px rgba(202, 203, 204, .5);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="添加网页进度加载条"><a href="#添加网页进度加载条" class="headerlink" title="添加网页进度加载条"></a>添加网页进度加载条</h4><p>编辑主题配置文件，ctrl+F搜索pace，将其值改为ture就可以了，选择一款你喜欢的样式。</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line"># Progress bar in the top during page loading.</span><br><span class="line">pace: true</span><br><span class="line"># Themes list:</span><br><span class="line">#pace-theme-big-counter</span><br><span class="line">#pace-theme-bounce</span><br><span class="line">#pace-theme-barber-shop</span><br><span class="line">#pace-theme-center-atom</span><br><span class="line">#pace-theme-center-circle</span><br><span class="line">#pace-theme-center-radar</span><br><span class="line">#pace-theme-center-simple</span><br><span class="line">#pace-theme-corner-indicator</span><br><span class="line">#pace-theme-fill-left</span><br><span class="line">#pace-theme-flash</span><br><span class="line">#pace-theme-loading-bar</span><br><span class="line">#pace-theme-mac-osx</span><br><span class="line">#pace-theme-minimal</span><br><span class="line"># For example</span><br><span class="line"># pace_theme: pace-theme-center-simple</span><br><span class="line">pace_theme: pace-theme-big-counter</span><br></pre></td></tr></table></figure>

<h3 id="引用本地图片"><a href="#引用本地图片" class="headerlink" title="引用本地图片"></a>引用本地图片</h3><p>1、把博客根目录配置文件_config.yml 里的post_asset_folder:这个选项设置为true</p>
<p>2、安装上传本地图片的插件</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">npm install hexo-asset-image --save</span><br></pre></td></tr></table></figure>
<p>3、安装完成后，新建文章时，会在&#x2F;source&#x2F;_posts文件夹内创建同名文件夹，将需要引用的图片放到这个文件夹内</p>
<p>4、引用图片</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">&#123;% asset_img myimage.jpg 这是一个博客的图片的描述 %&#125;</span><br></pre></td></tr></table></figure>
<p>myimage.jpg为图片名称，后面是图片的描述，图片描述可以为空。</p>
<h4 id="部署到GitHub超时"><a href="#部署到GitHub超时" class="headerlink" title="部署到GitHub超时"></a>部署到GitHub超时</h4><p>部署的时候推送到github时超时：</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">fatal: unable to access &#x27;https://github.com/RaphetS/RaphetS.github.io.git/&#x27;: Failed to connect to github.com port 443: Timed out</span><br></pre></td></tr></table></figure>

<p>解决办法：电脑开启vpn，并为git设置代理</p>
<p>①打开代理页面</p>
<p>电脑打开 设置 –&gt; 网络与Internet –&gt; 代理</p>
<p>记录下当前系统代理的 IP 地址和端口号</p>
<p>②git设置代理</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">git config --global http.proxy http://127.0.0.1:7890</span><br><span class="line">git config --global https.proxy http://127.0.0.1:7890</span><br></pre></td></tr></table></figure>

<p>@取消git代理</p>
<p>部署成功后，记得去掉</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">git config --global --unset http.proxy</span><br><span class="line">git config --global --unset https.proxy</span><br></pre></td></tr></table></figure>
<p>④查看git代理</p>
<p>确认下git代理是否取消</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">git config --global --get http.proxy</span><br><span class="line">git config --global --get https.proxy</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Hexo/" rel="tag"><i class="fa fa-tag"></i> Hexo</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item"></div>
      <div class="post-nav-item">
    <a href="/archives/17527.html" rel="next" title="Python 爬虫模拟登录的3种方法">
      Python 爬虫模拟登录的3种方法 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%89%8D%E8%A8%80"><span class="nav-number">1.</span> <span class="nav-text">一、前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C"><span class="nav-number">2.</span> <span class="nav-text">二、准备工作</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81Hexo%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA"><span class="nav-number">3.</span> <span class="nav-text">三、Hexo环境搭建</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81hexo%E7%AE%80%E4%BB%8B"><span class="nav-number">3.0.1.</span> <span class="nav-text">1、hexo简介</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E5%AE%89%E8%A3%85"><span class="nav-number">3.0.2.</span> <span class="nav-text">2、安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E5%88%9D%E5%A7%8B%E5%8C%96"><span class="nav-number">3.0.3.</span> <span class="nav-text">3、初始化</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5%E3%80%81%E7%94%9F%E6%88%90%E9%9D%99%E6%80%81%E6%96%87%E4%BB%B6"><span class="nav-number">3.0.4.</span> <span class="nav-text">5、生成静态文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6%E3%80%81%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1"><span class="nav-number">3.0.5.</span> <span class="nav-text">6、启动服务</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7%E3%80%81-hexo%E5%B8%B8%E8%A7%81%E5%91%BD%E4%BB%A4%E8%AF%B4%E6%98%8E"><span class="nav-number">3.0.6.</span> <span class="nav-text">7、 hexo常见命令说明</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#%E6%B8%85%E9%99%A4%E7%BC%93%E5%AD%98%E6%96%87%E4%BB%B6-db-json-%E5%92%8C%E5%B7%B2%E7%94%9F%E6%88%90%E7%9A%84%E9%9D%99%E6%80%81%E6%96%87%E4%BB%B6-public"><span class="nav-number">3.0.6.0.0.1.</span> <span class="nav-text">清除缓存文件 (db.json) 和已生成的静态文件 (public)</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#%E7%94%9F%E6%88%90%E9%9D%99%E6%80%81%E6%96%87%E4%BB%B6"><span class="nav-number">3.0.6.0.0.2.</span> <span class="nav-text">生成静态文件</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="nav-number">3.0.6.0.0.3.</span> <span class="nav-text">启动服务器</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#%E9%83%A8%E7%BD%B2%E7%BD%91%E7%AB%99"><span class="nav-number">3.0.6.0.0.4.</span> <span class="nav-text">部署网站</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#%E6%96%B0%E5%BB%BA%E6%96%87%E7%AB%A0"><span class="nav-number">3.0.6.0.0.5.</span> <span class="nav-text">新建文章</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#%E6%96%B0%E5%BB%BA%E9%A1%B5%E9%9D%A2"><span class="nav-number">3.0.6.0.0.6.</span> <span class="nav-text">新建页面</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E5%B0%86%E6%9C%AC%E5%9C%B0%E5%8D%9A%E5%AE%A2%E9%83%A8%E7%BD%B2%E5%88%B0GitHub"><span class="nav-number">4.</span> <span class="nav-text">四、将本地博客部署到GitHub</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Github%E5%9C%B0%E5%9D%80%E9%85%8D%E7%BD%AE"><span class="nav-number">4.0.1.</span> <span class="nav-text">Github地址配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8F%91%E5%B8%83%E5%8D%9A%E5%AE%A2"><span class="nav-number">4.0.2.</span> <span class="nav-text">发布博客</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81%E5%8D%9A%E5%AE%A2%E7%BE%8E%E5%8C%96"><span class="nav-number">5.</span> <span class="nav-text">五、博客美化</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9B%B4%E6%8D%A2%E4%B8%BB%E9%A2%98"><span class="nav-number">5.0.1.</span> <span class="nav-text">更换主题</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#1%E3%80%81%E4%B8%8B%E8%BD%BD%E4%B8%BB%E9%A2%98"><span class="nav-number">5.0.1.0.0.1.</span> <span class="nav-text">1、下载主题</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#2%E3%80%81%E4%BD%BF%E7%94%A8%E4%B8%BB%E9%A2%98"><span class="nav-number">5.0.1.0.0.2.</span> <span class="nav-text">2、使用主题</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%AD%E3%80%81%E6%B7%BB%E5%8A%A0gitment%E8%AF%84%E8%AE%BA%E7%B3%BB%E7%BB%9F"><span class="nav-number">6.</span> <span class="nav-text">六、添加gitment评论系统</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1%E3%80%81%E5%AE%89%E8%A3%85Gitment"><span class="nav-number">6.0.0.1.</span> <span class="nav-text">1、安装Gitment</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2%E3%80%81%E6%B3%A8%E5%86%8C-OAuth-Application"><span class="nav-number">6.0.0.2.</span> <span class="nav-text">2、注册 OAuth Application</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3%E3%80%81Gitment%E9%85%8D%E7%BD%AE"><span class="nav-number">6.0.0.3.</span> <span class="nav-text">3、Gitment配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4%E3%80%81%E5%88%9D%E5%A7%8B%E5%8C%96%E8%AF%84%E8%AE%BA"><span class="nav-number">6.0.0.4.</span> <span class="nav-text">4、初始化评论</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5%E3%80%81%E5%85%B3%E9%97%AD%E6%9F%90%E4%B8%AA%E9%A1%B5%E9%9D%A2%E7%9A%84%E8%AF%84%E8%AE%BA%E5%8A%9F%E8%83%BD"><span class="nav-number">6.0.0.5.</span> <span class="nav-text">5、关闭某个页面的评论功能</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6%E3%80%81%E9%97%AE%E9%A2%98"><span class="nav-number">6.0.0.6.</span> <span class="nav-text">6、问题</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E7%99%BB%E5%BD%95%E6%8A%A5%E9%94%99%EF%BC%8CObject-ProgressEvent"><span class="nav-number">6.0.0.6.1.</span> <span class="nav-text">登录报错，Object ProgressEvent</span></a></li></ol></li></ol></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%83%E3%80%81%E5%85%B6%E4%BB%96"><span class="nav-number">7.</span> <span class="nav-text">七、其他</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%AE%BE%E7%BD%AE%E3%80%8C%E9%98%85%E8%AF%BB%E5%85%A8%E6%96%87%E3%80%8D"><span class="nav-number">7.0.0.1.</span> <span class="nav-text">设置「阅读全文」</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%A6%96%E9%A1%B5%E6%96%87%E7%AB%A0%E6%B7%BB%E5%8A%A0%E9%98%B4%E5%BD%B1%E6%95%88%E6%9E%9C"><span class="nav-number">7.0.0.2.</span> <span class="nav-text">首页文章添加阴影效果</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%B7%BB%E5%8A%A0%E7%BD%91%E9%A1%B5%E8%BF%9B%E5%BA%A6%E5%8A%A0%E8%BD%BD%E6%9D%A1"><span class="nav-number">7.0.0.3.</span> <span class="nav-text">添加网页进度加载条</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BC%95%E7%94%A8%E6%9C%AC%E5%9C%B0%E5%9B%BE%E7%89%87"><span class="nav-number">7.0.1.</span> <span class="nav-text">引用本地图片</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%83%A8%E7%BD%B2%E5%88%B0GitHub%E8%B6%85%E6%97%B6"><span class="nav-number">7.0.1.1.</span> <span class="nav-text">部署到GitHub超时</span></a></li></ol></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="John Doe"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">John Doe</p>
  <div class="site-description" itemprop="description">不积跬步，无以至千里；不积小流，无以成江海。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">47</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">32</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">John Doe</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
